package java_persistence;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import domain.User;


public interface UserMapper {

	// CREATES
	
	/**saves a user to the database
	 * @param username the username of the patient - must be unique
	 * @param password the user's password
	 * @param name the user's name
	 * @param phone_number the user's phone number as a string
	 * @param address the user's address
	 * @param email the user's email address
	 * @param active_account a boolean that is true if the user is active and false otherwise
	 */
	public void create(@Param("username") String username,
						 @Param("password") String password,
						 @Param("name") String name,
						 @Param("phone_number") String phone_number,
						 @Param("address") String address,
						 @Param("email") String email,
						 @Param("active") Boolean active_account);
	
	/**saves a user object to the database
	 * @param u the user.  the user's username must be unique
	 */
	public void create2(User u);
	
	// RETRIEVES
	
	/**Retrieves a list of all users from the database.
	 * @return a list of Users
	 */
	public List<User> get_users();
	
	/**Retrieves a specific user from the database
	 * @param username the user's username
	 * @return a User object
	 */
	public User get_user_by_username(String username);
	
	/**Retrieves a user's password from the database given his/her username.
	 * @param username the user's username
	 * @return the user's password
	 */
	public String get_password_by_username(String username);
	
	// UPDATES
	
	/**Updates a user's details in the database.  It is not possible to change a user's username or to store a new user using this method.
	 * @param username the username of the user to update
	 * @param password the new password
	 * @param name the new name
	 * @param phone_number the new phone number as a string
	 * @param address the new address
	 * @param email the new email address
	 * @param active_account the new boolean representing true if it is an active account and false otherwise.
	 */
	public void update(@Param("username") String username,
						 @Param("password") String password,
						 @Param("name") String name,
						 @Param("phone_number") String phone_number,
						 @Param("address") String address,
						 @Param("email") String email,
						 @Param("active") Boolean active_account);
	
	/**Bans a user from loggin in 
	 * @param u the user to ban
	 */
	public void ban(User u); 
   
	// DELETES
	
	/**Deletes a user from the database.
	 * 
	 * Note that the user must not be demoted from being a Doctor, Nurse, Patient, or SystemAdministrator before being deleted and that this method will fail and generate an error if that is not done first.  
	 * 
	 * @param username the username of the user to delete.  
	 */
	public void delete(String username);
}
